<template>
  <div class="overview-item">
    <div class="el-icon-more">
      <div class="action">
        <el-button class="action-edit" icon="el-icon-edit-outline" @click="editHandle"></el-button>
        <el-button class="action-delete" icon="el-icon-delete" @click="deleteHandle"></el-button>
      </div>
    </div>
    <div class="mask"></div>

    <div class="top-wrap">
      <div class="label">任务名称</div>
      <h5 class="name" @click="detailHandle">{{ item.modelName }}</h5>
      <div class="label complete">完成度</div>
      <div class="percent-text" :style="progressTextStyle">
        {{ item.progress }}
      </div>
      <div class="progress-bar">
        <div class="cur-progress" :style="{...progressStyle}"></div>
      </div>
    </div>
    <div class="model-data-wrap">
      <div class="model-data">
        <div class="data-item">
          <div class="label">待办问题</div>
          <div class="data-value">
            <i class="icon-problem"></i>
            <span class="value">{{ item.problemNum }}</span>
          </div>
        </div>
        <div class="split-line"></div>
        <div class="data-item">
          <div class="label">重点问题</div>
          <div class="data-value">
            <i class="icon-focus"></i>
            <span class="value">{{ item.focusProblemNum }}</span>
          </div>
        </div>
      </div>
      <el-row class="sub-model-data">
        <el-col :span="6" class="data-item border-bottom">
          <div class="label">综合测试</div>
          <el-row class="data-row right">
            <el-col :span="12" class="data-value">
              <i class="icon-problem"></i>
              <span class="value">{{ item.testNum }}</span>
            </el-col>
            <el-col :span="12" class="data-value">
              <i class="icon-focus"></i>
              <span class="value">{{ item.testFocus }}</span>
            </el-col>
          </el-row>
        </el-col>
        <el-col :span="6" class="data-item border-left border-bottom">
          <div class="label">质量处理</div>
          <el-row class="data-row left right">
            <el-col :span="12" class="data-value" @click.native="noticeHandle(item.qualityNum, 'QUALITY', '质量处理', false)">
              <i class="icon-problem"></i>
              <span class="value">{{ item.qualityNum }}</span>
            </el-col>
            <el-col :span="12" class="data-value" @click.native="noticeHandle(item.qulityFocus, 'QUALITY', '质量处理', true)">
              <i class="icon-focus"></i>
              <span class="value">{{ item.qulityFocus }}</span>
            </el-col>
          </el-row>
        </el-col>
        <el-col :span="6" class="data-item border-left border-bottom">
          <div class="label">进度管理</div>
          <el-row class="data-row left right">
            <el-col :span="12" class="data-value"  @click.native="noticeHandle(item.progressNum, 'PRO', '进度管理', false)">
              <i class="icon-problem"></i>
              <span class="value">{{ item.progressNum }}</span>
            </el-col>
            <el-col :span="12" class="data-value" @click.native="noticeHandle(item.progressFocus, 'PRO', '进度管理', true)">
              <i class="icon-focus"></i>
              <span class="value">{{ item.progressFocus }}</span>
            </el-col>
          </el-row>
        </el-col>
        <el-col :span="6" class="data-item border-left border-bottom">
          <div class="label">技术状态</div>
          <el-row class="data-row left">
            <el-col :span="12" class="data-value" @click.native="noticeHandle(item.technologyNum, 'TECH', '技术状态', false)">
              <i class="icon-problem"></i>
              <span class="value">{{ item.technologyNum }}</span>
            </el-col>
            <el-col :span="12" class="data-value" @click.native="noticeHandle(item.technologyFocus, 'TECH', '技术状态', true)">
              <i class="icon-focus"></i>
              <span class="value">{{ item.technologyFocus }}</span>
            </el-col>
          </el-row>
        </el-col>
        <el-col :span="6" class="data-item">
          <div class="label">售后</div>
          <el-row class="data-row right">
            <el-col :span="12" class="data-value">
              <i class="icon-problem"></i>
              <span class="value">{{ 0 }}</span>
            </el-col>
            <el-col :span="12" class="data-value">
              <i class="icon-focus"></i>
              <span class="value">{{ 0 }}</span>
            </el-col>
          </el-row>
        </el-col>
        <el-col :span="6" class="data-item border-left">
          <div class="label">出入库</div>
          <el-row class="data-row left right">
            <el-col :span="12" class="data-value">
              <i class="icon-problem"></i>
              <span class="value">{{ 0 }}</span>
            </el-col>
            <el-col :span="12" class="data-value">
              <i class="icon-focus"></i>
              <span class="value">{{ 0 }}</span>
            </el-col>
          </el-row>
        </el-col>
        <el-col :span="6" class="data-item border-left">
          <div class="label">产品验收</div>
          <el-row class="data-row left right">
            <el-col :span="12" class="data-value">
              <i class="icon-problem"></i>
              <span class="value">{{ 0 }}</span>
            </el-col>
            <el-col :span="12" class="data-value">
              <i class="icon-focus"></i>
              <span class="value">{{ 0 }}</span>
            </el-col>
          </el-row>
        </el-col>
        <el-col :span="6" class="data-item border-left">
          <!-- <div class="label"></div>
          <el-row class="data-row left right">
            <el-col :span="12" class="data-value">
              <i class="icon-problem"></i>
              <span class="value">{{ 0 }}</span>
            </el-col>
            <el-col :span="12" class="data-value">
              <i class="icon-focus"></i>
              <span class="value">{{ 0 }}</span>
            </el-col>
          </el-row> -->
        </el-col>
      </el-row>
    </div>
    <div class="mask"></div>
  </div>
</template>

<script>
import { progressColorMap } from '@/utils/const.js'
export default {
  props: {
    item: {
      type: Object,
      default() {
        return {}
      },
    },
  },
  computed: {
    progressColor() {
      return { ...progressColorMap[this.item.modelColor.code || 'GREY'] }
    },
    progressTextStyle() {
      return `color: ${this.progressColor.color};`
    },
    progressStyle() {
      return {width: this.item.progress, background: this.progressColor.linearGradient,zIndex:99}
    },
  },
  methods: {
    editHandle() {
      this.$emit('edit', this.item)
    },
    deleteHandle() {
      this.$emit('delete', this.item)
    },
    detailHandle() {
      this.$emit('detail', this.item)
    },
    noticeHandle(count, type, label, isFocus) {
      console.log(type)
      if (count == 0) {
        return
      }


      this.$emit('notice', {
        model: this.item,
        typeData: {
          type,
          label
        },
        isFocus
      })
    }
  }
}
</script>

<style lang="scss" scoped>
.overview-item {
  position: relative;
  width: 444px;
  background-color: rgb(249, 249, 249);
  box-shadow: 0px 3px 7.76px 0.24px rgba(122, 128, 159, 0.15);
  border-radius: 5px;
  line-height: 1;
  font-family: 'Microsoft YaHei';
  overflow: hidden;

  .el-icon-more {
    position: absolute;
    top: 10px;
    right: 10px;
    padding: 0 6px;
    color: #505971;
    cursor: pointer;
    z-index: 2;
    overflow: visible;

    &:hover {
      background: #fff;
      box-shadow: inset 0 0 4px rgba(72, 133, 255, 0.8);

      .action{
        display: block;
      }

      & + .mask {
        display: block;
      }
    }

    .action {
      display: none;
      position: absolute;
      top: 100%;
      left: 0;
      padding-top: 3px;
      text-align: left;
    }

    .action-delete,
    .action-edit{
      margin: 0 0 2px 0;
      padding: 3px;
      font-size: 20px;
      border-radius: 3px;
      color: #285fe3;
      border: 1px solid #285fe3;

      &:hover,
      &:focus {
        color: #fff;
        background-color: #285fe3;
      }
    }
  }

  .mt-10 {
    margin-top: 10px;
  }

  .top-wrap {
    padding: 20px 16px 0 16px;
  }

  .label {
    font-size: 14px;
    color: #505971;
  }

  .name {
    margin: 8px 0 0 0;
    font-size: 18px;
    font-weight: normal;
    color: rgb(17, 20, 52);
    text-decoration: underline;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: pointer;

    &:hover {
      color: #4181ff;
    }
  }

  .complete {
    margin-top: 14px;
  }

  .mask {
    display: none;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 14, 42, 0.302);
    box-shadow: 0px 3px 7.76px 0.24px rgba(122, 128, 159, 0.15);
    border-radius: 5px;
    z-index: 1;
    cursor: default;
  }
}

.percent-text {
  margin-top: 4px;
  font-size: 16px;
  text-align: center;
}

.progress-bar {
  margin-top: 4px;
  height: 6px;
  border-radius: 3px;
  background-color: #d7dee6;
  overflow: hidden;
}
.cur-progress {
  height: 100%;
  border-radius: 3px;
}

.model-data-wrap {
  padding: 10px 7px 7px 7px;
  overflow: hidden;
  cursor: pointer;

  &:hover {
    .model-data {
      border-color: #4181ff;
    }

    & + .mask {
      display: block;
      z-index: 4;
    }
    .sub-model-data {
      bottom: 7px;
      z-index: 5;
    }
  }
}

.model-data {
  display: flex;
  justify-content: space-between;
  padding: 3px 0;
  border: 1px solid #d7dee6;
  border-radius: 3px;

  .split-line {
    width: 1px;
    background: #e2e8ef;
  }

  .data-item {
    flex: 1;
    flex-shrink: 0;
    padding: 0 13px;

    .label {
      margin-top: 6px;
      text-align: center;
    }
  }

  .data-value {
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 12px 0;
  }

  .value {
    margin-left: 10px;
    font-size: 30px;
    color: #111434;
  }
}

.icon-problem,
.icon-focus {
  width: 20px;
  height: 20px;
  background-repeat: no-repeat;
  background-size: 100%;
}

.icon-problem {
  background-image: url('../assets/icon/icon-problem.png');
}
.icon-focus {
  background-image: url('../assets/icon/icon-focus.png');
}

.sub-model-data {
  position: absolute;
  bottom: -140px;
  left: 7px;
  right: 7px;
  height: 140px;
  padding: 7px 12px;
  background-color: rgb(249, 249, 249);
  border-radius: 3px;
  box-shadow: inset 0 0 8px rgba(72, 133, 255, 0.8);
  z-index: 2;
  // transition: all 2s;

  .label {
    margin-top: 6px;
    text-align: center;
  }

  .data-item {
    height: 50%;
    cursor: default;

    &.border-bottom {
      border-bottom: 1px solid #d7dee6;
    }

    &.border-left {
      border-left: 1px solid #d7dee6;
    }
  }

  .data-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 16px;

    &.left {
      padding-left: 10px;
    }

    &.right {
      padding-right: 10px;
    }
  }

  .data-value {
    display: flex;
    align-items: center;
    cursor: pointer;

    &:nth-child(2) {
      justify-content: flex-end;
    }
  }

  .value {
    margin-left: 6px;
    font-size: 16px;
    color: #111434;
  }

  .icon-problem,
  .icon-focus {
    width: 14px;
    height: 14px;
  }
}
</style>
